﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Zgq.CommonTools
{
    /// <summary>
    /// 数据库操作接口
    /// </summary>
    public interface IC5SqlDB
    {
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="model"></param>
        /// <param name="sysDatabaseName"></param>
        /// <param name="sqlparameters"></param>
        /// <returns></returns>
        string GetInsertSql(object model, string sysDatabaseName = null, List<object> sqlparameters = null);

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="model"></param>
        /// /// <param name="sysDatabaseName"></param>
        /// <param name="sqlparameters"></param>
        /// <returns></returns>
        string GetUpdateSql(object model, string sysDatabaseName = null, List<object> sqlparameters = null);

        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="lists"></param>
        /// /// <param name="sysDatabaseName"></param>
        /// <param name="sqlparameters"></param>
        /// <returns></returns>
        string GetDeleteListSql(object[] lists, string sysDatabaseName = null, List<object> sqlparameters = null);

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="model"></param>
        /// /// <param name="sysDatabaseName"></param>
        /// <param name="sqlparameters"></param>
        /// <returns></returns>
        string GetDeleteSql(object model, string sysDatabaseName = null, List<object> sqlparameters = null);

        /// <summary>
        /// 查询数据是否存在
        /// </summary>
        /// <param name="model"></param>
        /// <param name="sysDatabaseName"></param>
        /// <param name="whereStr"></param>
        /// <returns></returns>
        string GetExistsSql(object model, string sysDatabaseName = null, string whereStr = null);

        /// <summary>
        /// 查询数据集
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="whereStr"></param>
        /// <param name="orderByStr"></param>
        /// <param name="sysDatabaseName"></param>
        /// <returns></returns>
        string SelectList<T>(string sysDatabaseName = null, string whereStr = null, string orderByStr = null);

        /// <summary>
        /// 查询分页数据集
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="whereStr"></param>
        /// <param name="orderByStr"></param>
        ///<param name="sysDatabaseName"></param>
        /// <returns></returns>
        string SelectListPaging<T>(int pageIndex, int pageSize, string sysDatabaseName = null, string whereStr = null, string orderByStr = null);

        /// <summary>
        /// 查询分页数据集 部分列
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="sysDatabaseName"></param>
        /// <param name="whereStr"></param>
        /// <param name="orderByStr"></param>
        /// <param name="colums"></param>
        /// <returns></returns>
        string SelectListPagingColumn<T>(int pageIndex, int pageSize, string sysDatabaseName = null, string whereStr = null, string orderByStr = null, params string[] colums);
        
        /// <summary>
        /// 查询实体
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="sysDatabaseName"></param>
        /// <param name="whereStr"></param>
        /// <returns></returns>
        string SelectModel<T>(string sysDatabaseName = null, string whereStr = null, string orderByStr = null);

        /// <summary>
        /// 查询组合视图数据集
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="whereStr"></param>
        /// <param name="orderByStr"></param>
        /// <returns></returns>
        string GetViewListSql<T>(string whereStr = null, string orderByStr = null);

        /// <summary>
        /// 查询组合视图分页数据集
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="whereStr"></param>
        /// <param name="orderByStr"></param>
        /// <returns></returns>
        string GetViewListPagingSql<T>(int pageIndex, int pageSize, string whereStr = null, string orderByStr = null);

        /// <summary>
        /// 查询数据总量
        /// </summary>
        /// <param name="sysDatabaseName"></param>
        /// <param name="whereStr"></param>
        /// <returns></returns>
        string SelectModelCount<T>(string sysDatabaseName = null, string whereStr = null);

        /// <summary>
        /// 查询Datatable
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="sysDatabaseName"></param>
        /// <param name="whereStr"></param>
        /// <param name="orderStr"></param>
        /// <param name="colums"></param>
        /// <returns></returns>
        string SelectDatatable(string tableName, string sysDatabaseName = null, string whereStr = null, string orderStr = null, params string[] colums);

        /// <summary>
        /// 查询Datatable启用分页
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="sysDatabaseName"></param>
        /// <param name="whereStr"></param>
        /// <param name="orderStr"></param>
        /// <param name="colums"></param>
        /// <returns></returns>
        string SelectDatatablePaging(string tableName, int pageIndex, int pageSize, string sysDatabaseName = null, string whereStr = null, string orderStr = null, params string[] colums);

        /// <summary>
        /// 查询数据总量
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="sysDatabaseName"></param>
        /// <param name="whereStr"></param>
        /// <returns></returns>
        string SelectDatatableCount(string tableName, string sysDatabaseName = null, string whereStr = null);
    }
}
